package com.dingreading.cloud.admin.controller;

import com.alibaba.excel.EasyExcel;
import com.dingreading.cloud.admin.dto.HeadStaffDto;
import com.dingreading.cloud.admin.dto.StoreManagementFeeDto;
import com.dingreading.cloud.admin.entity.StoreManagementFee;
import com.dingreading.cloud.admin.entity.StoreManagementFeeImg;
import com.dingreading.cloud.admin.entity.Stores;
import com.dingreading.cloud.admin.service.StaffService;
import com.dingreading.cloud.admin.service.StoreManagementFeeImgService;
import com.dingreading.cloud.admin.service.StoreManagementFeeService;
import com.dingreading.cloud.admin.service.StoresService;
import com.dingreading.cloud.admin.util.AdminStaffRoleUtil;
import com.dingreading.cloud.admin.util.HeadStaffUtil;
import com.dingreading.cloud.admin.util.StoreFollowEnum;
import com.dingreading.cloud.admin.util.StoreFollowUtil;
import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.*;
import com.dingreading.cloud.common.util.excel.ExcelHandler;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;

@RefreshScope
@RestController
@RequestMapping("/system/storeManagementFee")
@Api(tags = "总部-门店管理费管理")
public class StoreManagementFeeController {

    @Value("${aliYun.oss.dingreadingBucketUrl}")
    private String dingreadingBucketUrl;

    @Resource
    private StoresService storesService;
    @Resource
    private StoreManagementFeeService managementFeeService;
    @Resource
    private StoreManagementFeeImgService feeImgService;
    @Resource
    protected HeadStaffUtil headStaffUtil;
    @Resource
    protected StaffService staffService;


    @ApiOperation(value = "分页列表")
    @PostMapping(value = "/pageList")
    public R<Object> pageList(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid", required = false) String storeUid,
            @ApiParam(value = "缴费状态 1.已缴 0.未缴 -1.已关闭") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(value = "缴费开始日期 yyyy-MM-dd") @RequestParam(value = "beginDate", required = false) String beginDate,
            @ApiParam(value = "缴费结束日期 yyyy-MM-dd") @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(value = "缴费日期排序 1.正序 0.倒序") @RequestParam(value = "orderStatus", required = false) Integer orderStatus
    ) {
        HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
        List<String> identifyList = loginInfo.getIdentifyList();
        if (CollectionUtils.isEmpty(identifyList))
            return R.fail("未发现账号的角色");

        Page<StoreManagementFeeDto> page = managementFeeService.pageList(
                pageUtil, storeUid, headStaffUid, status, beginDate, endDate, orderStatus, identifyList
        );

        List<StoreManagementFeeDto> list = page.getRecords();
        if (CollectionUtils.isNotEmpty(list)) {
            List<String> corpUidList = list.stream().map(StoreManagementFeeDto::getCorpUid).collect(Collectors.toList());

            Map<String, String> lastLoginMap = staffService.lastLoginTimeLog(corpUidList);
            for (StoreManagementFeeDto dto : list) {
                dto.setLastLoginTime(lastLoginMap.get(dto.getCorpUid()));
            }

        }

        PageBeanDto data = new PageBeanDto();
        data.setTotal(page.getTotalRow());
        data.setList(list);
        return R.ok(data);
    }

    @ApiOperation(value = "按门店uid获取管理费列表")
    @PostMapping(value = "/getList")
    public R<Object> getList(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid", required = false) String storeUid
    ) {
        List<StoreManagementFee> list = managementFeeService.listByStoreUid(storeUid);

        return R.ok(list);
    }

    @ApiOperation(value = "根据id获取信息")
    @PostMapping(value = "/getBean", produces = "application/json; charset=UTF-8")
    public R<Object> getBean(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id") Long id
    ) {
        StoreManagementFee data = managementFeeService.getByIdRalation(id);
        if (null == data)
            return R.fail("未查询到信息");

        return R.ok(data);
    }

    @Transactional(rollbackFor = DescribeException.class)
    @ApiOperation(value = "创建/更新管理费信息")
    @PostMapping(value = "/newBean", produces = "application/json; charset=UTF-8")
    public R<Object> newBean(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id", required = false) Long id,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "到期时间") @RequestParam(value = "expiryTime") String expiryTime,
            @ApiParam(value = "应缴金额") @RequestParam(value = "amount") Double amount
    ) throws Exception {
        if (StringUtils.isBlank(expiryTime))
            return R.fail("请选择选择到期时间");
        if (amount == null || amount <= 0)
            return R.fail("请填写正确的金额");

        HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
        List<String> identifyList = loginInfo.getIdentifyList();
        if (CollectionUtils.isEmpty(identifyList))
            return R.fail("未发现账号的角色");
        boolean superAdmin = AdminStaffRoleUtil.isSuperAdmin(identifyList);
        boolean manager = AdminStaffRoleUtil.isManager(identifyList);

        String followType = "";
        StoreManagementFee data = null;
        if (null == id || id <= 0) {
            Stores stores = storesService.getByUid(storeUid);
            if (stores == null)
                return R.fail("未查询到门店");

            followType = StoreFollowEnum.MANAGEMENT_FEE_ADD.getType();
            data = new StoreManagementFee();
            data.setAddStaffUid(headStaffUid);
            data.setAddStaffName(headStaffName);
            data.setCorpUid(stores.getCorpUid());
            data.setStoreUid(storeUid);
            data.setStatus(0);
        } else {
            data = managementFeeService.getById(id);
            if (null == data)
                return R.fail("未查询到");
            if (data.getStatus().equals(1))
                return R.fail("已缴费，不能操作");
            if (!superAdmin && !manager) {
                if (TimeUtil.moreThanDay(data.getAddTime(), 30))
                    return R.fail("录入超过30天，不能操作");
            }
            followType = StoreFollowEnum.MANAGEMENT_FEE_EDIT.getType();
        }
        data.setAmount(amount);
        data.setExpiryTime(DateUtil.parseDate(expiryTime));
        data.setLastStaffUid(headStaffUid);
        data.setLastStaffName(headStaffName);
        managementFeeService.saveOrUpdate(data);

        // 跟进记录
        StoreFollowUtil.newSystemLog(
                followType, "应缴时间：" + expiryTime + "，应缴金额：" + amount,
                data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
        );
        return R.ok();
    }

    @Transactional(rollbackFor = DescribeException.class)
    @ApiOperation(value = "经理创建/更新管理费信息")
    @PostMapping(value = "/mangerAdd", produces = "application/json; charset=UTF-8")
    public R<Object> mangerAdd(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id", required = false) Long id,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "到期时间") @RequestParam(value = "expiryTime") String expiryTime,
            @ApiParam(value = "应缴金额") @RequestParam(value = "amount") Double amount
    ) throws Exception {
        if (StringUtils.isBlank(expiryTime))
            return R.fail("请选择选择到期时间");
        if (amount == null || amount <= 0)
            return R.fail("请填写正确的金额");

        HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
        List<String> identifyList = loginInfo.getIdentifyList();
        if (CollectionUtils.isEmpty(identifyList))
            return R.fail("未发现账号的角色");
        boolean superAdmin = AdminStaffRoleUtil.isSuperAdmin(identifyList);
        boolean manager = AdminStaffRoleUtil.isManager(identifyList);
        if (!superAdmin && !manager)
            return R.fail("不是超管或经理，不能操作");

        String followType = "";
        StoreManagementFee data = null;
        if (null == id || id <= 0) {
            Stores stores = storesService.getByUid(storeUid);
            if (stores == null)
                return R.fail("未查询到门店");

            followType = StoreFollowEnum.MANAGEMENT_FEE_ADD.getType();
            data = new StoreManagementFee();
            data.setAddStaffUid(headStaffUid);
            data.setAddStaffName(headStaffName);
            data.setCorpUid(stores.getCorpUid());
            data.setStoreUid(storeUid);
            data.setStatus(0);
        } else {
            data = managementFeeService.getById(id);
            if (null == data)
                return R.fail("未查询到");
            if (data.getStatus().equals(1))
                return R.fail("已缴费，不能操作");
            followType = StoreFollowEnum.MANAGEMENT_FEE_EDIT.getType();
        }
        data.setAmount(amount);
        data.setExpiryTime(DateUtil.parseDate(expiryTime));
        data.setLastStaffUid(headStaffUid);
        data.setLastStaffName(headStaffName);
        managementFeeService.saveOrUpdate(data);

        // 跟进记录
        StoreFollowUtil.newSystemLog(
                followType, "应缴时间：" + expiryTime + "，应缴金额：" + amount,
                data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
        );
        return R.ok();
    }

    @ApiOperation(value = "更新管理费为已缴费")
    @PostMapping(value = "/updateStatus", produces = "application/json; charset=UTF-8")
    public R<Object> updateStatus(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id") Long id,
            @ApiParam(value = "实缴金额") @RequestParam(value = "payAmount") Double payAmount,
            @ApiParam(value = "实缴时间") @RequestParam(value = "payTime") String payTime,
            @ApiParam(value = "缴费凭证（图片）") @RequestBody() List<StoreManagementFeeImg> imgList,
            @ApiParam(value = "缴费备注") @RequestParam(value = "remark", required = false) String remark
    ) throws Exception {
        if (StringUtils.isBlank(payTime))
            return R.fail("请选择缴费时间");
        if (CollectionUtils.isEmpty(imgList))
            return R.fail("请上传缴费凭证");

        StoreManagementFee data = managementFeeService.getById(id);
        if (null == data)
            return R.fail("未查询到信息");

        if (data.getStatus().equals(0)) {
            // 更新为缴费
            Date payDate = DateUtil.parseDate(payTime);
            boolean b = managementFeeService.updateStatus(id, payAmount, payDate, remark, headStaffUid, headStaffName);
            if (!b)
                return R.fail("缴费失败");

            for (StoreManagementFeeImg img : imgList) {
                if (img.getId() == null || img.getId() <= 0) {
                    img.setAddStaffUid(headStaffUid);
                    img.setAddStaffName(headStaffName);
                    img.setFeeId(data.getId());
                }
            }
            feeImgService.saveOrUpdateBatch(imgList);

            // 跟进记录
            StoreFollowUtil.newSystemLog(
                    StoreFollowEnum.MANAGEMENT_FEE_PAY.getType(), "实缴时间：" + payTime + "，实缴金额：" + payAmount,
                    data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
            );
        } else if (data.getStatus().equals(1)) {
            HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
            List<String> identifyList = loginInfo.getIdentifyList();
            if (CollectionUtils.isEmpty(identifyList))
                return R.fail("未发现账号的角色");
            boolean superAdmin = AdminStaffRoleUtil.isSuperAdmin(identifyList);
            boolean manager = AdminStaffRoleUtil.isManager(identifyList);
            if (superAdmin) {
                if (TimeUtil.moreThanDay2(data.getPayTime(), 720))
                    return R.fail("缴费已超" + 720 + "天，不能操作");
            } else {
                int limitDay = manager ? 365 : 180;
                if (TimeUtil.moreThanDay2(data.getPayTime(), limitDay))
                    return R.fail("缴费已超" + limitDay + "天，不能操作");
            }

            // 更新缴费截图
            List<StoreManagementFeeImg> newImgList = new ArrayList<>();
            for (StoreManagementFeeImg img : imgList) {
                if (img.getId() == null || img.getId() <= 0) {
                    img.setAddStaffUid(headStaffUid);
                    img.setAddStaffName(headStaffName);
                    img.setFeeId(data.getId());
                    newImgList.add(img);
                }
            }
            feeImgService.saveOrUpdateBatch(newImgList);
            // 更新缴费信息
            Date payDate = DateUtil.parseDate(payTime);
            boolean b = managementFeeService.updateStatus(id, payAmount, payDate, remark, headStaffUid, headStaffName);
            if (!b)
                return R.fail("缴费失败");

            // 跟进记录
            StoreFollowUtil.newSystemLog(
                    StoreFollowEnum.MANAGEMENT_FEE_PAY.getType(), "更新缴费信息，" + "实缴时间：" + payTime + "，实缴金额：" + payAmount,
                    data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
            );
        } else {
            return R.fail("已关闭，不能操作");
        }

        return R.ok(data);
    }

    @ApiOperation(value = "删除管理费")
    @PostMapping(value = "/deleteBean", produces = "application/json; charset=UTF-8")
    public R<Object> deleteBean(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id") Long id
    ) {
        StoreManagementFee data = managementFeeService.getById(id);
        if (data == null)
            return R.fail("未查询到");
        if (data.getStatus().equals(1))
            return R.fail("已缴费，不能操作");

        HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
        List<String> identifyList = loginInfo.getIdentifyList();
        if (CollectionUtils.isEmpty(identifyList))
            return R.fail("未发现账号的角色");
        boolean superAdmin = AdminStaffRoleUtil.isSuperAdmin(identifyList);
        boolean manager = AdminStaffRoleUtil.isManager(identifyList);
        if (!superAdmin && !manager) {
            return R.fail("不是超管或经理，不能操作");
        } else {
            if (TimeUtil.moreThanDay(data.getAddTime(), 30))
                return R.fail("录入超过30天，不能操作");
        }

        boolean b = managementFeeService.removeById(id);
        if (!b)
            return R.failDel();

        // 跟进记录
        StoreFollowUtil.newSystemLog(
                StoreFollowEnum.MANAGEMENT_FEE_DELETE.getType(),
                "应缴时间：" + DateUtil.getDefaultTimeStr(data.getExpiryTime()) + "，应缴金额：" + data.getAmount(),
                data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
        );

        return R.ok();
    }

    @ApiOperation(value = "关闭管理费")
    @PostMapping(value = "/close", produces = "application/json; charset=UTF-8")
    public R<Object> close(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id") Long id,
            @ApiParam(value = "关闭原因") @RequestParam(value = "closeRemark") String closeRemark
    ) {
        HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
        List<String> identifyList = loginInfo.getIdentifyList();
        if (CollectionUtils.isEmpty(identifyList))
            return R.fail("未发现账号的角色");
        boolean superAdmin = AdminStaffRoleUtil.isSuperAdmin(identifyList);
        boolean manager = AdminStaffRoleUtil.isManager(identifyList);
        if (!superAdmin && !manager) {
            return R.fail("不是超管或经理，不能操作");
        }

        StoreManagementFee data = managementFeeService.getById(id);
        if (data == null)
            return R.fail("未查询到");
        if (data.getStatus().equals(1)) {
            return R.fail("已缴费，不能操作");
        }

        boolean b = managementFeeService.close(id, closeRemark, headStaffUid, headStaffName);
        if (!b)
            return R.fail("操作失败");

        // 跟进记录
        StoreFollowUtil.newSystemLog(
                StoreFollowEnum.MANAGEMENT_FEE_CLOSE.getType(),
                "应缴时间：" + DateUtil.getDefaultTimeStr(data.getExpiryTime()) + "，应缴金额：" + data.getAmount() + " 被关闭，关闭原因：" + closeRemark,
                data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
        );

        return R.ok();
    }

    @ApiOperation(value = "恢复未缴费")
    @PostMapping(value = "/recover", produces = "application/json; charset=UTF-8")
    public R<Object> recover(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "id") @RequestParam(value = "id") Long id
    ) {
        StoreManagementFee data = managementFeeService.getById(id);
        if (data == null)
            return R.fail("未查询到");
        if (data.getStatus().equals(1)) {
            HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
            List<String> identifyList = loginInfo.getIdentifyList();
            boolean manager = AdminStaffRoleUtil.isSuperAdmin(identifyList);
            boolean superAdmin = AdminStaffRoleUtil.isSuperAdmin(identifyList);
            if (!superAdmin) {
                int limitDay = manager ? 365 : 30;
                if (TimeUtil.moreThanDay(data.getPayTime(), limitDay)) {
                    return R.fail("缴费超过" + limitDay + "天，不能操作");
                }
            }
        } else {
            return R.fail("管理费的状态异常");
        }

        boolean b = managementFeeService.recover(id, headStaffUid, headStaffName);
        if (!b)
            return R.fail("操作失败");

        feeImgService.deleteByFeeId(id);

        // 跟进记录
        StoreFollowUtil.newSystemLog(
                StoreFollowEnum.MANAGEMENT_FEE_RECOVER.getType(),
                "应缴时间：" + DateUtil.getDefaultTimeStr(data.getExpiryTime()) + "，应缴金额：" + data.getAmount() + "，已缴费 恢复为 未缴费",
                data.getCorpUid(), data.getStoreUid(), headStaffUid, headStaffName
        );

        return R.ok();
    }

    @ApiOperation(value = "导出")
    @PostMapping(value = "/export")
    public void export(
            HttpServletResponse response,
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid", required = false) String storeUid,
            @ApiParam(value = "缴费状态 1.已缴 0.未缴 -1.已关闭") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(value = "缴费开始日期 yyyy-MM-dd") @RequestParam(value = "beginDate", required = false) String beginDate,
            @ApiParam(value = "缴费结束日期 yyyy-MM-dd") @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(value = "缴费日期排序 1.正序 0.倒序") @RequestParam(value = "orderStatus", required = false) Integer orderStatus
    ) throws Exception {
        HeadStaffDto loginInfo = headStaffUtil.getLoginInfo(headStaffUid);
        List<String> identifyList = loginInfo.getIdentifyList();
        if (CollectionUtils.isEmpty(identifyList))
            throw new DescribeException("未发现账号的角色");

        if (StringUtils.isBlank(beginDate) || StringUtils.isBlank(endDate)) {
            // 获取本月的第一天和最后一天
            Date monthMinDate = DateUtil.getMonthMinDate();
            Date monthMaxDate = DateUtil.getMonthMaxDate();
            beginDate = DateUtil.getDefaultTime2DateStr(monthMinDate);
            endDate = DateUtil.getDefaultTime2DateStr(monthMaxDate);
        }

        List<StoreManagementFee> list = managementFeeService.listByExport(
                storeUid, headStaffUid, status, beginDate, endDate, orderStatus, identifyList
        );
        if (CollectionUtils.isEmpty(list))
            throw new DescribeException("未查询到数据，" + beginDate + "至" + endDate);

        // 表格头部列的数据
        List<List<String>> headList = new ArrayList<>();
        // 表格第一列默认是门店名称
        headList.add(Collections.singletonList("门店名称"));
        headList.add(Collections.singletonList("应缴金额"));
        headList.add(Collections.singletonList("应缴日期"));
        headList.add(Collections.singletonList("实缴金额"));
        headList.add(Collections.singletonList("缴费信息"));
        headList.add(Collections.singletonList("缴费凭证"));
        headList.add(Collections.singletonList("缴费备注"));
        headList.add(Collections.singletonList("缴费状态"));
        headList.add(Collections.singletonList("添加信息"));
        headList.add(Collections.singletonList("修改信息"));
        // 表格内的数据
        List<List<Object>> dataList = new ArrayList<>();

        for (StoreManagementFee fee : list) {
            List<Object> data = new ArrayList<>();
            data.add(fee.getStoreName());
            data.add(fee.getAmount());

            if (fee.getExpiryTime() != null) {
                data.add(DateUtil.getDefaultTime2DateStr(fee.getExpiryTime()));
            } else {
                data.add("");
            }

            data.add(fee.getPayAmount());

            if (StringUtils.isNotBlank(fee.getOperatorName())) {
                String payTime = fee.getPayTime() != null ? DateUtil.getDefaultTime2DateStr(fee.getPayTime()) : "";
                data.add(fee.getOperatorName() + "\n" + payTime);
            } else {
                data.add("");
            }

            StringBuilder fileList = new StringBuilder();
            List<StoreManagementFeeImg> imgList = fee.getImgList();
            if (CollectionUtils.isNotEmpty(imgList)) {
                for (StoreManagementFeeImg img : imgList) {
                    String ossUrl = dingreadingBucketUrl + img.getUrl();
                    fileList.append(ossUrl).append("\n");

                }
            }
            data.add(fileList.toString());

            data.add(fee.getRemark());
            if (fee.getStatus().equals(-1)) {
                data.add("已关闭\n" + fee.getCloseRemark());
            } else if (fee.getStatus().equals(1)) {
                data.add("已缴费");
            } else if (fee.getStatus().equals(0)) {
                data.add("未缴费");
            } else {
                data.add("");
            }
            data.add(fee.getAddStaffName() + "\n" + DateUtil.getDefaultTimeStr(fee.getAddTime()));
            data.add(fee.getLastStaffName() + "\n" + DateUtil.getDefaultTimeStr(fee.getEditTime()));

            dataList.add(data);
        }

        String fileName = "门店管理费" + beginDate + "至" + endDate;
        EasyExcel.write(ExcelHandler.getOutputStream(fileName, response))
                // 设置单元格样式
                .registerWriteHandler(ExcelHandler.getCellStyleStrategy())
                .head(headList)
                .sheet("门店管理费")
                .doWrite(dataList);
    }

}